package GUI;
/**
 * Select a class in order to select a student
 * the selection is made to simplify the list of students registered in our System
 */

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class SelectClassForExAdd extends JPanel {
	
	
	private JComboBox cBSelClass = null;
	private JLabel lblSelectClass = null;
	private JButton btnNext=null;
	
	public String selectedClass=null;
	public Login myLoginFrame = null;
	public UserAdmin user=null;
	public AdminMainMenu amn=null;
	private SelectStudentForExAdd SelectStudentForExAdd = null;
	private SelectStudentForEx selStudForExScreen=null;
	private Vector<String> data=null;
	
	
	
	public SelectClassForExAdd(AdminMainMenu amn) {
		super();
		initialize(amn);
			
	}
	
	
	public JButton getNextButton()
	{
		if(btnNext==null)
		{
			btnNext = new JButton("Next");
			btnNext.setBounds(324, 230, 89, 23);
			btnNext.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					user.SetClass(selectedClass);
					
					SelectStudentForExAdd=amn.getselStudForExAddScreen();
					amn.setContentPane(SelectStudentForExAdd);
				
				
					
				}
			});
			
		}
		
		return btnNext;
			
	}
	private void initialize(AdminMainMenu amn)
	{
		setLayout(null);
		lblSelectClass = new JLabel("Select Class:");
		lblSelectClass.setBounds(45, 84, 74, 14);
		
		add(lblSelectClass);
		add(getSelClassCb(amn.user.DataForEx.Classes));
		add(getNextButton());
		
	}
	
	
	
	public JComboBox getSelClassCb(Vector<String> Class)
	{
		
	
		
		cBSelClass  = new JComboBox(Class);
		cBSelClass.setBounds(139, 81, 243, 20);
		//cBSelClass.insertItemAt("Select Student", 1);
		cBSelClass.addActionListener(new java.awt.event.ActionListener() {
	
		public void actionPerformed(java.awt.event.ActionEvent e) {
		selectedClass= cBSelClass.getSelectedItem().toString();
		amn.user.SetClass(selectedClass);
		
		System.out.println(selectedClass);
		 
		
		
		 	}
		
	
		});

		return cBSelClass;
	}

}
